import request from '@/utils/http'
import { BaseResult, PaginationResult } from '@/types/axios'

export class FoodsService {
  // 获取商品列表
  static getFoodsSourceList(params?: any) {
    return request.get<BaseResult<PaginationResult<any>>>({
      url: '/get_food_source_list',
      params
    })
  }
  // 查询食物源通过名称
  static getFoodsSourceByTitle(title: any) {
    return request.get<BaseResult<PaginationResult<any>>>({
      url: '/get_food_source_by_title',
      params: { title }
    })
  }
  // 添加食物源
  static addFoodsSource(data: any) {
    return request.post<BaseResult<PaginationResult<any>>>({
      url: '/add_food_source',
      data
    })
  }
  // 修改食物源
  static updateFoodsSource(data: any) {
    return request.post<BaseResult<PaginationResult<any>>>({
      url: '/update_food_source_by_id',
      data
    })
  }
  // 删除食物源
  static delFoodsSource(id: number | string) {
    return request.post<BaseResult<PaginationResult<any>>>({
      url: '/del_food_source_by_id',
      params: { id }
    })
  }
  // 餐食列表
  static getFoodsList(params: any) {
    return request.get<BaseResult<PaginationResult<any>>>({
      url: '/get_food_list',
      params
    })
  }
  // 添加食物
  static addFoods(data: any) {
    return request.post<BaseResult<PaginationResult<any>>>({
      url: '/add_food',
      data
    })
  }
  // 修改食物
  static updateFoods(data: any) {
    return request.post<BaseResult<PaginationResult<any>>>({
      url: '/update_food_by_id',
      data
    })
  }
  // 删除食物
  static delFood(id: number | string) {
    return request.post<BaseResult<PaginationResult<any>>>({
      url: '/delFoodById',
      data: { id }
    })
  }
}
